package com.farmer.finance.controller;

import com.farmer.common.result.Result;
import com.farmer.finance.service.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/financeService")
public class FinanceServiceController {

    @Autowired
    private FinanceService financeService;

    @GetMapping("/list")
    public Result<?> list(@RequestParam(required = false) String type,
            @RequestParam(required = false) Long userId,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        return financeService.list(type, userId, pageNum, pageSize);
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody com.farmer.common.entity.FinanceService entity) {
        return financeService.add(entity);
    }

    @PutMapping("/update")
    public Result<?> update(@RequestBody com.farmer.common.entity.FinanceService entity) {
        return financeService.update(entity);
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> delete(@PathVariable Long id) {
        return financeService.delete(id);
    }

    @GetMapping("/{id}")
    public Result<?> detail(@PathVariable Long id) {
        return financeService.detail(id);
    }
}